// copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
// see COPYRIGHT for reuse legalities
//

#import "RIBPerspective.h"

@implementation RIBPerspective

+ initialize { return [RIBPerspective setVersion:1], self; }

- init
{
  [super init];
  fov = 45.0;

  return self;
}

- (float)fov {  return fov; }


- setFOV:(float)newFOV
{
  fov = newFOV;
  return self;
}

- renderSelf:(WW3DCamera *)camera  startingAt:(RtFloat)shutterOpenTime endingAt:(RtFloat)shutterCloseTime
{
  RiPerspective(fov);

  return self;
}

- transformCTM:(WW3DAttributeState *)attributeState startingAt:(RtFloat)shutterOpenTime endingAt:(RtFloat)shutterCloseTime
{ 
  NXLogError("Warning: should be concatenating a Perspective matrix on the CTM...\n");
  return self; 
}

- (BOOL)isMotionBlurrable { return YES; }

#define typeVector "f"
#define typeValues &fov

- read:(NXTypedStream*)stream 
{
    int version;
    [super read:stream];

    version = NXTypedStreamClassVersion(stream,"RIBPerspective");
    if (version == 0) NXReadTypes(stream,"i",&version), version=1;
    if (version == 1)
    {  NXReadTypes(stream,typeVector,typeValues);
    } 
    else 
    {
    }
    return self;
}

- write:(NXTypedStream*)stream 
{
    [super write:stream];

    NXWriteTypes(stream,typeVector, typeValues);

    return self;
}


@end
